package br.ucb.sacop.webservice;

import java.util.ArrayList;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import br.ucb.sacop.R;
import br.ucb.sacop.bean.Aluno;

public class ListaAlunos extends ListActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		ArrayList<Aluno> listaAlunos = new ArrayList<Aluno>();

		if (getIntent().hasExtra("lista")) {

			listaAlunos = ((ArrayList<Aluno>) getIntent().getExtras()
					.getSerializable("lista"));
		}

		setListAdapter(new ArrayAdapter<Aluno>(this, R.layout.list_item,
				listaAlunos));

		ListView lv = getListView();
		lv.setTextFilterEnabled(true);

		lv.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				// When clicked, show a toast with the TextView text
				Toast.makeText(getApplicationContext(),
						((TextView) view).getText(), Toast.LENGTH_SHORT).show();
			}
		});

	}

}
